var service_user = require("../../service/user.js");

Page({
  data: {

  },
  onShow:function(){
    var templates = [];
    templates[getApp().globalData.userInfo.template] = 1
    this.setData({
      templates: templates
    })
  },
  select: function (e) {
    var id = e.currentTarget.id;
    var templates = [];
    templates[id] = 1
    if (id > 5 && !getApp().globalData.userInfo.is_vip) {
      wx.showModal({
        title: '提示',
        content: '您还不是VIP，马上获得VIP权限>>>',
        success: function (res) {
          if (res.confirm == true) {
            wx.switchTab({
              url: '/pages/find2/find2',
            })
          }
        }
      })
    } else {
      this.setData({
        templates: templates
      })
      var userInfo = getApp().globalData.userInfo;
      userInfo["template"] = id;
      service_user.saveUserInfo(userInfo, function () {
        wx.switchTab({
          url: '/page/index/index',
        })
      });
    }
  }
})